package co.th.helper.jdbc.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import co.th.helper.jdbc.RowMapper;
import co.th.helper.model.DepartmentOfHospital;

public class DepartmentOfHospitalRowMapper extends RowMapper<DepartmentOfHospital>{

	@Override
	public DepartmentOfHospital mapRow(ResultSet resultSet) throws SQLException {
		DepartmentOfHospital deptHos = new DepartmentOfHospital();
		if (isThere(resultSet, "hospital_code")){
			deptHos.setHospitalCode(resultSet.getBigDecimal("hospital_code"));
		}
		
		if (isThere(resultSet, "hospital_dept_code")){
			deptHos.setHospitalDepartmentCode(resultSet.getBigDecimal("hospital_dept_code"));
		}
		
		if (isThere(resultSet, "hospital_dept_name_th")){
			deptHos.setHospitalDepartmentNameTh(resultSet.getString("hospital_dept_name_th"));
		}
		
		if (isThere(resultSet, "hospital_dept_name_en")){
			deptHos.setHospitalDepartmentNameEn(resultSet.getString("hospital_dept_name_en"));
	    }
		
		if (isThere(resultSet, "director_code")){
			deptHos.setDirector(resultSet.getBigDecimal("director_code"));
		}
		
		if (isThere(resultSet, "bed_capacity_min")){
			deptHos.setBedCapacityMin(resultSet.getBigDecimal("bed_capacity_min"));
		}
		
		if (isThere(resultSet, "bed_capacity_max")){
			deptHos.setBedCapacityMax(resultSet.getBigDecimal("bed_capacity_max"));
		}
		
		if (isThere(resultSet, "create_by")){
			deptHos.setCreateBy(resultSet.getString("create_by"));
		}
		
		if (isThere(resultSet, "create_date")){
			deptHos.setCreateDate(resultSet.getDate("create_date"));
		}
		
		if (isThere(resultSet, "update_by")){
			deptHos.setUpdateBy(resultSet.getString("update_by"));
		}
		
		if (isThere(resultSet, "update_date")){
			deptHos.setUpdateDate(resultSet.getDate("update_date"));
		}
		
		return deptHos;
	}
}
